<?php include 'dbInclude.php';?>
<table>
<tr class="tbhd"><td>Company</td><td>Quantity</td><td>Balance</td><td>Current Balance</td><td>Profit/Loss</td></tr>
<?php
ob_start();
    session_start();
	
    if(isset($_SESSION['sess_client_id']) && !empty($_SESSION['sess_client_id'])) {
		$clid = $_SESSION['sess_client_id'];
	$rows=$dbh->query("select im.INSTR_NAME, pm.INSTR_ID, pm.QUANTITY, pm.BALANCE from portfolio_master pm join instrument_master im on pm.INSTR_ID=im.INSTR_ID where CLIENT_ID = ".$clid." ;");
foreach ($rows as $row) {
echo "<tr>";
$instName = $row['INSTR_NAME'];
$instid = $row['INSTR_ID'];
$qnty = $row['QUANTITY'];
$bal = $row['BALANCE'];
echo "<td>".$instName."</td>";
echo "<td>".$qnty."</td>";
echo "<td>".$bal."</td>";

$rows1 = $dbh->query("select * from market where INSTR_ID=".$instid." ;");

foreach ($rows1 as $row) {
	$ltp = $row["LTP"];	
}
$final = $ltp * $qnty;
$ans = $final-$bal;
echo "<td>".$final."</td>";
echo "<td class='price'>".$ans."</td>";
echo "</tr>";
}
}
?>
</table>


